App({
  globalData: {
    userInfo: null,
    interviewHistory: [],
    categories: [
      {
        id: 1,
        name: "技术面试",
        icon: "icon-tech",
        color: "#165DFF",
        questions: [
          {
            id: 101,
            question: "请简要介绍一下React的生命周期",
            category: "技术面试",
            difficulty: "中等"
          },
          {
            id: 102,
            question: "什么是闭包？闭包有什么作用？",
            category: "技术面试",
            difficulty: "中等"
          },
          {
            id: 103,
            question: "简述JavaScript的事件冒泡和事件捕获",
            category: "技术面试",
            difficulty: "中等"
          },
          {
            id: 104,
            question: "简述CSS盒模型",
            category: "技术面试",
            difficulty: "简单"
          },
          {
            id: 105,
            question: "如何优化前端性能？",
            category: "技术面试",
            difficulty: "中等"
          }
        ]
      },
      {
        id: 2,
        name: "行为面试",
        icon: "icon-behavior",
        color: "#36CFC9",
        questions: [
          {
            id: 201,
            question: "请举例说明你曾经如何解决团队中的冲突",
            category: "行为面试",
            difficulty: "中等"
          },
          {
            id: 202,
            question: "描述一个你面对挑战并成功克服的经历",
            category: "行为面试",
            difficulty: "中等"
          },
          {
            id: 203,
            question: "你如何管理时间和优先级？",
            category: "行为面试",
            difficulty: "简单"
          },
          {
            id: 204,
            question: "请分享一次你在工作中犯错的经历，以及你从中学习到了什么",
            category: "行为面试",
            difficulty: "中等"
          },
          {
            id: 205,
            question: "你如何在压力下工作？",
            category: "行为面试",
            difficulty: "简单"
          }
        ]
      },
      {
        id: 3,
        name: "产品面试",
        icon: "icon-product",
        color: "#FF7D00",
        questions: [
          {
            id: 301,
            question: "如果你负责设计一款新的社交产品，你会关注哪些用户需求？",
            category: "产品面试",
            difficulty: "中等"
          },
          {
            id: 302,
            question: "如何评估一个产品功能的成功与否？",
            category: "产品面试",
            difficulty: "中等"
          },
          {
            id: 303,
            question: "描述一次你必须做出艰难产品决策的经历",
            category: "产品面试",
            difficulty: "中等"
          },
          {
            id: 304,
            question: "如何进行用户调研？",
            category: "产品面试",
            difficulty: "简单"
          },
          {
            id: 305,
            question: "如果你发现产品的用户留存率低，你会采取什么措施？",
            category: "产品面试",
            difficulty: "中等"
          }
        ]
      },
      {
        id: 4,
        name: "管理面试",
        icon: "icon-management",
        color: "#722ED1",
        questions: [
          {
            id: 401,
            question: "如何激励和管理一个多样化的团队？",
            category: "管理面试",
            difficulty: "中等"
          },
          {
            id: 402,
            question: "描述你的领导风格",
            category: "管理面试",
            difficulty: "简单"
          },
          {
            id: 403,
            question: "如何培养和发展团队成员的技能？",
            category: "管理面试",
            difficulty: "中等"
          },
          {
            id: 404,
            question: "如何处理表现不佳的团队成员？",
            category: "管理面试",
            difficulty: "中等"
          },
          {
            id: 405,
            question: "如何在有限的资源下实现团队目标？",
            category: "管理面试",
            difficulty: "中等"
          }
        ]
      }
    ]
  },
  
  onLaunch: function() {
    // 获取用户信息
    this.getUserInfo();
    
    // 尝试从本地存储加载面试历史
    const history = wx.getStorageSync('interviewHistory');
    if (history) {
      this.globalData.interviewHistory = history;
    }
  },
  
  getUserInfo: function() {
    wx.getUserInfo({
      success: res => {
        this.globalData.userInfo = res.userInfo;
      },
      fail: err => {
        console.log('获取用户信息失败', err);
      }
    });
  },
  
  addInterviewRecord: function(record) {
    this.globalData.interviewHistory.unshift(record);
    wx.setStorageSync('interviewHistory', this.globalData.interviewHistory);
  }
});
